package com.hs.sfzy.mapper;

import com.hs.sfzy.entity.Course;
import com.hs.sfzy.entity.CourseDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface CourseMapper {


    List<Course> selectAll(CourseDTO courseDTO);

    int save(Course course);

    @Delete("delete from course where id = #{id}")
    int deleteById(Integer id);

    int update(Course course);

    Course selectById(Long id);

    List<Course> selectForWx(Map map);

    @Update("update course set course.grade = (select ifnull(avg(coursemark.grade),0) " +
            "from coursemark where course_id = course.id) where course.id = #{courseId}")
    int updateCourseGrade(int courseId);
}
